/*
 * Copyright (C), 2002-2017, 苏宁易购电子商务有限公司
 * FileName: ExchangeCouponRecordDaoImpl
 * Author:   15030469 胡丹
 * Date:     2017/5/3 10:00
 * Description: //模块目的、功能描述      
 * History: //修改记录
 * <author>      <time>      <version>    <desc>
 * 修改人姓名             修改时间            版本号                  描述
 */
package com.suning.sawp.service.impl.dao.exchange;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.google.common.collect.Maps;
import com.suning.framework.dal.client.DalClient;
import com.suning.sawp.dto.exchange.ExchangeOrderCouponRecord;
import com.suning.sawp.intf.dao.exchange.ExchangeCouponRecordDao;
import com.suning.sawp.po.exchange.ExchangeCouponRecord;
import com.suning.sawp.vo.exchange.CouponRecordVo;

/**
 * 〈订单发券记录 dao 实现类〉<br>
 *
 * @author 15030469 胡丹
 */
@Repository
public class ExchangeCouponRecordDaoImpl implements ExchangeCouponRecordDao {

    @Resource(name = "dalClient")
    private DalClient dalClient;
    @Resource(name = "dalClientRead")
    private DalClient dalClientRead;

    @Override
    public void saveCouponRecord(ExchangeCouponRecord exchangeCouponRecord) {
        dalClient.persist(exchangeCouponRecord);
    }

    @Override
    public List<CouponRecordVo> filterCouponRecord(String employeeId, int startRow, int rows) {
        Map<String, Object> param = Maps.newHashMap();
        param.put("employeeId", employeeId);
        param.put("startRow", startRow);
        param.put("rows", rows);
        return dalClientRead.queryForList("exchange.couponRecord.filterCouponRecord", param, CouponRecordVo.class);
    }

    @Override
    public int countTotal(String employeeId) {
        Map<String, Object> param = Maps.newHashMap();
        param.put("employeeId", employeeId);
        return dalClientRead.queryForObject("exchange.couponRecord.countTotal", param, Integer.class);
    }

    @Override
    public List<ExchangeOrderCouponRecord> queryOrderCoupon(String orderNo) {
        Map<String, Object> param = Maps.newHashMap();
        param.put("orderNo", orderNo);
        return dalClientRead.queryForList("exchange.couponRecord.orderCouponList", param,
                ExchangeOrderCouponRecord.class);
    }
}
